#ifndef TESTPLUGIN_H
#define TESTPLUGIN_H

#include "Poco/Foundation.h"
#include "Poco/ClassLibrary.h"
#include "aqnode.h"
#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <opencv2/highgui.hpp>
#include <math.h>
#include <iostream>

class TestPlugin
{
public:
    TestPlugin(void){}
    virtual ~TestPlugin(void){}
    virtual std::string name() const=0;
};


class MsrcrNode: public aq::Node
{
public:
    MsrcrNode(){
            needed_input_source_ = 1;
        this->control_pm_setted_ = true;
        this->run_pm_setted_ = true;
//        this->need_re_init_ = /*false*/;
    }
    ~MsrcrNode(){}

    bool set_control_params(std::string _params){
        std::cout << "set_control_params" << std::endl;
        return true;
    }
    bool get_control_params(std::string& _params){
        std::cout << "get_control_params" << std::endl;
        return true;
    }
    bool set_run_params(std::string _params){
                std::cout << "set_run_params" << std::endl;
        return true;
    }
    bool get_run_params(std::string& _params){
                std::cout << "get_run_params" << std::endl;
        return true;
    }
    bool get_process_type_name(std::string& _name){return "cutter";}

    //////////////////////////////////////
    bool process_impl(){


        std::cout << "cutter provcessing" << std::endl;

        //  为MultiScaleRetinexCR( ) 提供sigmas 初始值，该初始值为最优值，后期可通过外部设定获得当时作业环境下的最优值，从而达到最好效果
        sigmas.push_back(15);
        sigmas.push_back(162);
        sigmas.push_back(270);

        sourceImage = cv::imread("xxxxx.jpg");

        MultiScaleRetinexCR( sourceImage, dstImage, sigmas);   // dstImage 为源图像， dstImage 为处理后的目标图像

        cv::imshow(" xxxx", dstImage);


        return true;
    }
    bool init_impl(){
        std::cout << "cutter initing" << std::endl;
        return true;
    }

    bool must_set_needed_input_source_first(){
        needed_input_source_ = 1;
        return true;
    }

    std::vector<int> sigmas;

    cv::Mat sourceImage, dstImage;

private:
    void FastFilter(cv::Mat& src, double sigma);
    void MultiScaleRetinexCR(const cv::Mat &src, cv::Mat &dst, std::vector<int> sigmas,
                                        int gain = 128, int offset = 128, double restoration_factor = 6, double color_gain = 2);



};

POCO_BEGIN_MANIFEST(aq::Node)
POCO_EXPORT_CLASS(MsrcrNode)
POCO_END_MANIFEST

#endif // TESTPLUGIN_H
